{% extends "admin/base.html" %}

{% block title %}{{ '編輯資訊' if news else '添加資訊' }} - 管理後台{% endblock %}

{% block page_title %}{{ '編輯資訊' if news else '添加資訊' }}{% endblock %}

{% block content %}
<div class="card">
    <div class="card-body">
        <form method="POST">
            <div class="mb-3">
                <label class="form-label">中文標題</label>
                <input type="text" class="form-control" name="zh_title" 
                       value="{{ news.zh_title if news else '' }}" required>
            </div>
            <div class="mb-3">
                <label class="form-label">英文標題</label>
                <input type="text" class="form-control" name="en_title" 
                       value="{{ news.en_title if news else '' }}" required>
            </div>
            <div class="mb-3">
                <label class="form-label">分類</label>
                <select class="form-select" name="category" required>
                    <option value="company" {{ 'selected' if news and news.category == 'company' }}>公司動態</option>
                    <option value="industry" {{ 'selected' if news and news.category == 'industry' }}>行業資訊</option>
                    <option value="tech" {{ 'selected' if news and news.category == 'tech' }}>技術分享</option>
                </select>
            </div>
            <div class="mb-3">
                <label class="form-label">中文內容</label>
                <textarea class="form-control" name="zh_content" rows="10" required>{{ news.zh_content if news else '' }}</textarea>
            </div>
            <div class="mb-3">
                <label class="form-label">英文內容</label>
                <textarea class="form-control" name="en_content" rows="10" required>{{ news.en_content if news else '' }}</textarea>
            </div>
            <div class="text-end">
                <a href="{{ url_for('admin.news') }}" class="btn btn-secondary">取消</a>
                <button type="submit" class="btn btn-primary">保存</button>
            </div>
        </form>
    </div>
</div>
{% endblock %} 